exports.handler = function(sid, query, callback) {
    var db = gServers.getGameDB(sid);
    if (!db) {
       callback('db eror'); return;
    }
    
    var day = query.day || 30;
    var level = query.level || 50;
    var vip = query.vip || 0;

    var markDay = Date.createFromStamp(Date.getStamp() - day*86400).getDateNumber();
    var condition = {
        'mark.day': {'$lt':markDay},
        'status.level': {'$lte':level},
        'status.vip': {'$lte':vip},
    };

    db.collection('user').remove(condition, {}, function(err, result) {
        if (err) {
            LOG(util.format('sid=%d failed, err=%j', sid, err));
        } else {
            LOG(util.format('sid=%d success', sid));
        }
        callback(err);
    });
}

exports.help = function() {
    return [
        "[day=30] [level=50] [vip=0]",
        "清理用户,未登录天数>=day,等级<=level,VIP等级<=vip",
    ];
}

exports.master = true;
